import java.awt.*;

import javax.swing.*;

import java.awt.event.*;

public class test extends JFrame{
	
	static JPanel contentPane;
	static JDesktopPane desktop;
	static Container timelineContainer;
	static Container animationContainer;
	static Container toolboxContainer;
	static timeline timeline;
	static toolbox toolbox;
	static animation animation;
	static int openFrameCount = 0;
	static final int xOffset = 30, yOffset = 30;
	static newFile newF;
	static test frame;
	static int inset = 50;
    static Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    static int width = screenSize.width  - inset*2;
    static int height = screenSize.height - inset*2;
	
	public test(){
		super("Test");	
		
		 //Make the big window be indented 50 pixels from each edge
        //of the screen.
        
        setBounds(inset, inset, width, height);
        createContentPane();
        
        //addPalette(); //create first "window"
        setContentPane(desktop);
        //setContentPane(timelinePane);
        final menuBar menu = new menuBar(this);
        setJMenuBar(menu);
        

        //Make dragging a little faster but perhaps uglier.
        desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
		
	}

	
	public static JInternalFrame addPalette(){
		JInternalFrame palette = new JInternalFrame(("New Animation " + (++openFrameCount)), true, true, true, true);
		palette.setVisible(true);
		palette.toFront();
		animationContainer.add(palette);
		palette.setSize(animationContainer.getWidth(), animationContainer.getHeight());
		palette.setBackground(Color.blue);
		
		palette.moveToFront();
		
		return palette;
	}
	
	public static JPanel getPane(){
		return contentPane;
	}
	
	 public Container createContentPane() {
	        //Create the content-pane-to-be.
	        contentPane = new JPanel(new BorderLayout());
	        contentPane.setOpaque(true);
	        
	        desktop = new JDesktopPane();
	        contentPane.add(desktop, BorderLayout.CENTER);
	        desktop.setBackground(Color.white);
	        
	        timelineContainer = new Container();
	        animationContainer = new Container();
	        toolboxContainer = new Container();
	        
	        animationContainer.setSize((width*4/5), (height*5/7));
	        timelineContainer.setSize(width, (height*2/7));
	        toolboxContainer.setSize((width*1/5), (height*5/7));
	        
	        animationContainer.setLocation((width*1/5), 0);
	        timelineContainer.setLocation(0, (height*5/7));
	        toolboxContainer.setLocation(0,0);
	        
	        desktop.add(animationContainer, BorderLayout.EAST);
	        desktop.add(timelineContainer, BorderLayout.SOUTH);
	        desktop.add(toolboxContainer, BorderLayout.WEST);
	        
	        animationContainer.add(animation.add(animationContainer, openFrameCount));
	        timelineContainer.add(timeline.add());
	        toolboxContainer.add(toolbox.add());

	        return contentPane;
	    }
	
	private static void createAndShowGUI() {
        JFrame.setDefaultLookAndFeelDecorated(true);

        //Create and set up the window.
        frame = new test();
        newF = new newFile(frame);
        frame.add(newF);
        frame.transferFocus();
        
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        //Display the window.
        frame.setVisible(true);
        newF.createAndShowGUI();
        
    }
	
	
	
	
	public static void main(String args[]) {
		javax.swing.SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                createAndShowGUI();
                if(!newF.hasFocus()&&newF.isShowing()){
                	frame.transferFocusBackward();
                }
            }
        });
	}
}
